Euler's method is a simple but effective method to give approximation to solutions of IVPs of the type
$$\frac{dy}{dt} = f(t, y), \quad y(t_0) = y_0. \tag{1}$$The main idea in Euler's method is essentially a first order (i.e., tangent line) approximation to an unknown solution of the IVP. Let $\phi(t)$ be a solution to (1). So we have $\phi(t_0) = y_0$. Thus
$$\left.\frac{dy}{dt}\right|_{t_0} = f(t_0, y_0)$$is the gradient of $y$ at the point $(t_0, y_0)$. We can write down the tangent line equation to the $y$ at this point $(t_0, y_0)$:
Suppose we now choose $t_1 > t_0$ and $t_1$ is close to $t_0$. Then the value
$$y_1 = y_0 + f(t_0, y_0)(t_1 - t_0)$$gives an approximation to $\phi(t_1)$.
At $(t_0, y_0)$, we draw the tangent line with slope $f(t_0, y_0)$. Moving along this tangent line to $t = t_1$ gives us the approximate value $y_1$. The closer $t_1$ is to $t_0$, the better the approximation.
We take $t = t_1$ as our focus. Thus
$$\left.\frac{dy}{dt}\right|_{t_1} = f(t_1, y_1)$$is the gradient of $y$ at the point $(t_1, y_1)$ which gives an approximation to the real gradient
$$\left.\frac{dy}{dt}\right|_{t_1} = f(t_1, \phi(t_1)).$$The tangent line equation is given by
$$y = y_1 + f(t_1, y_1)(t - t_1)$$at $(t_1, y_1)$. We now choose $t_2 > t_1$ but close to $t_1$ as in the last step so that
$$y_2 = y_1 + f(t_1, y_1)(t_2 - t_1)$$and
$$\left.\frac{dy}{dt}\right|_{t_2} = f(t_2, y_2)$$is an approximation to
$$\left.\frac{dy}{dt}\right|_{t_2} = f(t_2, \phi(t_2)).$$We now obtain a tangent line equation
$$y = y_2 + f(t_2, y_2)(t - t_2)$$at $(t_2, y_2)$.
We can continue the above process repeatedly to obtain a sequence $t_1, t_2, t_3, \ldots$ and approximate values $y_1, y_2, y_3, \cdots$ to arrive at:
The following algorithm
where $f_n = f(t_n, y_n)$, would give approximations to the IVP
$$\frac{dy}{dt} = f(t, y), \quad y(t_0) = y_0.$$The union of the polygonal segments through the points
$$(t_0, y_0), \quad (t_1, y_1), \quad (t_2, y_2), \quad \cdots$$gives an approximation to the real solution $y = \phi(t)$.
In practical implementation, we write $h = t_{n+1} - t_n$ as a fixed quantity for all $n \geq 1$. So,
The constant $h$ is called the step size.
Use Euler's method to solve numerically the IVP:
$$\frac{dy}{dt} = 3 + e^{-t} - \frac{1}{2}y, \quad y(0) = 1.$$So we identify $t_0 = 0$ and $y_0 = 1$. Let us choose the step size $h = 0.1$ and $t_0 = 0$.
Here, $f(t, y) = 3 + e^{-t} - \frac{y}{2}$.
According to Euler's method, we have
\begin{align} y_1 &= y_0 + f(t_0, y_0) \cdot h \\[6pt] &= 1 + \left(3 + e^0 - \frac{1}{2}\right)(0.1) \\[6pt] &= 1 + (3.5)(0.1) = 1.35. \end{align}So the first approximation is $(t_1, y_1) = (0.1, 1.35)$.
Now
\begin{align} y_2 &= y_1 + f(t_1, y_1) \cdot h \\[6pt] &= 1.35 + \left(3 + e^{-0.1} - \frac{1.35}{2}\right)(0.1) \\[6pt] &= 1.35 + (3.2298)(0.1) = 1.672. \end{align}We have therefore obtained our second approximation: $(t_2, y_2) = (0.2, 1.672)$.
Similarly,
\begin{align} y_3 &= y_2 + f(t_2, y_2) \cdot h \\[6pt] &= 1.672 + \left(3 + e^{-0.2} - \frac{1.672}{2}\right)(0.1) \\[6pt] &= 1.971. \end{align}Thus, $(t_3, y_3) = (0.3, 1.971)$, similarly $(t_4, y_4) = (0.4, 2.246), \cdots$.
| $t$ | Euler's approximation |
|---|---|
| 0.0 | 1.0000 |
| 0.1 | 1.3500 |
| 0.2 | 1.6730 |
| 0.3 | 1.9712 |
| 0.4 | 2.2467 |
This DE can be solved explicitly, for example, by integrating factor method:
A comparison of the approximate values obtained from Euler's method and that from the exact solution, we have, with step size $h = 0.1$:
| $t$ | $\phi(t)$ (exact) | Euler's approx. | Error |
|---|---|---|---|
| 0.0 | 1.0000 | 1.0000 | 0.0000 |
| 0.1 | 1.3366 | 1.3500 | 0.0134 |
| 0.2 | 1.6480 | 1.6730 | 0.0250 |
| 0.3 | 1.9362 | 1.9712 | 0.0350 |
| 0.4 | 2.2032 | 2.2467 | 0.0435 |
Notice that the error accumulates as we take more steps. At $t = 0.4$, the error is about 2% of the actual value. The error grows because each approximation is based on the previous (already approximate) value.
We record here several comparisons with decreasing step sizes:
| step | $t$ | $y$ | global error |
|---|---|---|---|
| 0 | 0. | 1. | 0. |
| 1 | 0.1 | 1.35 | −0.0133631 |
| 2 | 0.2 | 1.67298 | −0.0249575 |
| 3 | 0.3 | 1.97121 | −0.034968 |
| 4 | 0.4 | 2.24673 | −0.0435614 |
| 5 | 0.5 | 2.50142 | −0.0508883 |
| step | $t$ | $y$ | global error |
|---|---|---|---|
| 0 | 0. | 1. | 0. |
| 4 | 0.1 | 1.33988 | −0.00324277 |
| 8 | 0.2 | 1.65409 | −0.00605954 |
| 12 | 0.3 | 1.94473 | −0.00849458 |
| 16 | 0.4 | 2.21376 | −0.0105878 |
| 20 | 0.5 | 2.46291 | −0.0123754 |
Decreasing the step size from $h = 0.1$ to $h = 0.025$ reduces the global error at $t = 0.5$ from about $0.051$ to about $0.012$ — roughly a 4-fold improvement (since $0.1/0.025 = 4$).
In general, halving the step size approximately halves the error for Euler's method. This is because Euler's method has first-order accuracy.
Please ignore the "local error" column in numerical outputs. The "global error" column represents the error with the Euler approximation against the real solution (not always given by exact solutions).
Find approximate values of the solution of the initial value problem
$$y' = 3 + t - y, \quad y(0) = 0$$at $t = 0.1, 0.2, 0.3,$ and $0.4$ using the Euler method with $h = 0.1$.
(Ans. 1.2, 1.39, 1.571, 1.7439)Find approximate values of the solution of the initial value problem of
$$y' = \frac{3t^2}{3y^2 - 4}, \quad y(1) = 0$$at $t = 1.2, 1.4, 1.6,$ and $1.8$ using the Euler method with $h = 0.1$.
(Ans. −0.166134, −0.410872, 0.804660, 4.15867)Consider the IVP: $\;\dfrac{dy}{dt} = f(t, y), \quad y(t_0) = y_0$
What is the geometric idea behind Euler's method?
In Euler's formula $y_{n+1} = y_n + f_n \cdot h$, what does $f_n$ represent?
What does $h$ represent, and how does it affect accuracy?
Given $y_0 = 1$, $f(t_0, y_0) = 3.5$, and $h = 0.1$, what is $y_1$?
If the exact solution at $t_1 = 0.1$ is $\phi(0.1) = 1.3366$, what is the error of Euler's approximation $y_1 = 1.35$?
Solve using Euler's method with $h = 0.1$:
$$y' = 3 + t - y, \quad y(0) = 0$$Find $y$ at $t = 0.1, 0.2, 0.3, 0.4$.
What is $f(t, y)$ for this problem?
What is $f_0 = f(t_0, y_0) = f(0, 0)$?
Calculate $y_1 = y_0 + f_0 \cdot h$:
At $(t_1, y_1) = (0.1, 0.3)$: $f_1 = 3 + 0.1 - 0.3 = 2.8$. What is $y_2$?
At $(t_2, y_2) = (0.2, 0.58)$: $f_2 = 3 + 0.2 - 0.58 = 2.62$. What is $y_3$?
At $(t_3, y_3) = (0.3, 0.842)$: $f_3 = 3 + 0.3 - 0.842 = 2.458$. What is $y_4$?
Note: The textbook answer gives $y(0.4) \approx 1.7439$. This problem may have a typo or the answer key refers to different values. The method demonstrated here is correct.
Summary: $(0.1, 0.3), (0.2, 0.58), (0.3, 0.842), (0.4, 1.088)$
Solve using Euler's method with $h = 0.1$:
$$y' = \frac{3t^2}{3y^2 - 4}, \quad y(1) = 0$$Find $y$ at $t = 1.1$ and $t = 1.2$.
What potential issue exists with this DE at the initial condition $y(1) = 0$?
Calculate $f_0 = f(1, 0) = \dfrac{3(1)^2}{3(0)^2 - 4}$:
Calculate $y_1 = y_0 + f_0 \cdot h = 0 + (-0.75)(0.1)$:
At $(t_1, y_1) = (1.1, -0.075)$, calculate $f_1 = \dfrac{3(1.1)^2}{3(-0.075)^2 - 4}$:
Hint: $3(1.1)^2 = 3.63$ and $3(0.075)^2 = 0.016875$
$y_2 = y_1 + f_1 \cdot h = -0.075 + (-0.911)(0.1) = ?$
Excellent! Your answer $y(1.2) \approx -0.166$ matches the textbook answer of $-0.166134$.
Note: This problem has a singularity when $3y^2 = 4$, i.e., $y = \pm\sqrt{4/3} \approx \pm 1.155$. As the solution evolves, be aware of this potential issue.
Consider Euler's method applied to any IVP with step size $h$.
If halving the step size (from $h$ to $h/2$) roughly halves the error, what is Euler's method called?
Why does the global error in Euler's method tend to grow as $t$ increases?
If step size $h = 0.1$ gives error $\approx 0.05$ at some $t$, what error would you expect with $h = 0.025$?
— End of Euler's Numerical Method Notes —